package com.ruoyi.web.controller.hospital;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.audit.HPatientAudit;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.core.text.Convert;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.hospital.domain.HPatient;
import com.ruoyi.hospital.domain.vo.HSyntheticalVo;
import com.ruoyi.hospital.service.IHSyntheticalQueryService;
import com.ruoyi.hospital.service.IHpatientService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 综合查询controller
 * @author liz
 * @date 2023-10-18 11:09
 */
@RestController
@RequestMapping("hospital/synthetical")
public class HSyntheticalQueryController extends BaseController {

    @Autowired
    IHSyntheticalQueryService syntheticalQueryService;

    @Autowired
    IHpatientService hpatientService;

    /**
     * 获取患者列表
     */
    @PreAuthorize("@ss.hasPermi('hospital:synthetical:list')")
    @GetMapping("/list")
    public TableDataInfo list(HPatient patient) {
        startPage();
        List<HPatient> patientList = syntheticalQueryService.selectSyntheticalList(patient);
        return getDataTable(patientList);
    }
    /**
     * 根据Id获取患者详情和报销详情
     */
    @PreAuthorize("@ss.hasPermi('hospital:synthetical:detail')")
    @GetMapping(value="/detail/{id}")
    public AjaxResult selectById(@PathVariable Integer id) {
        return success(hpatientService.selectById(id));
    }

    @PreAuthorize("@ss.hasPermi('hospital:synthetical:export')")
    @PostMapping("/export")
    public void export(HttpServletResponse response, HPatient hPatient) {
        List<HPatient> patientList = syntheticalQueryService.selectSyntheticalList(hPatient);
        ExcelUtil<HPatient> util = new ExcelUtil<HPatient>(HPatient.class);
        util.exportExcel(response, patientList, "综合查询");
    }
}
